function getModelStr(moduleName) {
	const Name = moduleName.substr(0, 1).toUpperCase() + moduleName.substring(1);
	let str = `<template>
	<div class="table-box">
		<div class="card table-search">
			<el-form ref="formRef" :model="searchParam" label-width="auto">
				<el-row :gutter="30">
					<el-col :span="12">
						<el-form-item>
							<el-button type="primary" @click="search()">搜索</el-button>
							<el-button @click="resetForm(formRef)">清空</el-button>
						</el-form-item>
					</el-col>
				</el-row>
			</el-form>
		</div>
		<div class="card table">
			<div class="table-header">
				<el-button type="primary" @click="openDialog('新增')">新增</el-button>
				<el-button type="danger" @click="onDelete" :disabled="tableSelected.length === 0">批量删除</el-button>
			</div>
			<el-table stripe :data="tableList" @selection-change="tableSelected = $event">
				<el-table-column type="selection" width="55"> </el-table-column>
				<el-table-column type="index" width="50"> </el-table-column>
			</el-table>
			<el-pagination
				@size-change="getList"
				@current-change="getList"
				v-model:currentPage="paginationParam.page"
				v-model:page-size="paginationParam.size"
				:page-sizes="[10, 50, 100]"
				layout="total, sizes, prev, pager, next, jumper"
				:total="listTotal"
			>
			</el-pagination>
		</div>
	</div>
	<Dialog ref="dialogRef" @edited="getList"></Dialog>
</template>

<script setup lang="ts">
import { delete${Name}, get${Name} } from "@/api/modules/${moduleName}";
import { ElMessage, FormInstance, ElMessageBox } from "element-plus";
import { reactive, ref, onBeforeMount } from "vue";
import Dialog from "./components/dialog.vue";

onBeforeMount(() => {
	getList();
});

const formRef = ref<FormInstance>();
const dialogRef = ref();
const searchParam = reactive({});
const paginationParam = reactive({ page: 1, size: 10 });
const listTotal = ref(0);
// 表格选中行
const tableSelected = ref<any[]>([]);
const tableList = ref<any[]>([]);
const getList = () => {
	get${Name}({
		...paginationParam,
		...searchParam
	}).then(res => {
		tableList.value = res.data.list;
		listTotal.value = res.data.total;
	});
};

const search = () => {
	paginationParam.page = 1;
	getList();
};

const resetForm = (formRef: FormInstance | undefined) => {
	if (!formRef) return;
	formRef.resetFields();
};

const openDialog = (title = "新增", row: Partial<any> = {}) => {
	let params = {
		title,
		onlyRead: title === "详情",
		rowData: { ...row }
	};
	dialogRef.value.acceptParams(params);
};

const onDelete = () => {
	ElMessageBox.confirm("您确定要删除吗", "提示").then(() => {
		const ids = tableSelected.value.map(item => item.id);
		delete${Name}({ ids }).then(() => {
			ElMessage.success("删除成功");
			getList();
		});
	});
};
</script>

<style scoped></style>
`;

	return str;
}

module.exports = getModelStr;
